<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:xf="http://www.w3.org/2002/xforms"
	xmlns:ev="http://www.w3.org/2001/xml-events"
	xmlns:ebforms="http://code.google.com/p/eb-forms">
	<head>
		<title>Inbox</title>
		
		<style type="text/css">
			@namespace xf url("http://www.w3.org/2002/xforms");
			
			xf|trigger xf|label {
				font-family: Helvetica, Geneva, Lucida, sans-serif;
				font-weight: normal;
				font-size: 1.1em;
			}
		</style>
		
		<xf:model><!-- schema="file:../schemas/transform-config.xsd" -->
		
			<!--
				Keep this as the first instance. The submission did not work when 
				instance.messages was the first instance. This shouldn't be the case I 
				guess but for now leaving this as the first instance solves the problem.
			-->
			<xf:instance id="instance.config" src="transform-config.xml" />
			
			<xf:instance id="instance.mesages"
				src="http://10.122.91.22:8088/get_message_list" />
			
			<xf:submission id="save.config" method="put" 
				action="file:../tf-read.xml" replace="none"
				includenamespaceprefixes="#default"
				instance="instance.config" />
			
			<xf:load ev:event="xforms-submit-done" 
				resource="javascript:parent.showIncommingMessage()"/>
		</xf:model>
	</head>
	<body>
		<h1>Berichten</h1>
		<div>
			<xf:repeat id="messages-repeat" nodeset="instance( 'instance.mesages' )/file">
				<xf:trigger appearance="minimal">
					<xf:label>- </xf:label>
					<xf:label ref="@src" />
					<!-- First change some values in 'instance.config' -->
					<xf:action ev:event="DOMActivate">
						<!--
						<xf:setvalue ref="instance( 'instance.config' )
								/ebforms:output/ebforms:filename/@src"
							value="instance( 'instance.mesages' )
								/file[index('messages-repeat')]/@src" />
						-->
						
						<xf:setvalue ref="instance( 'instance.config' )
								/ebforms:mode/ebforms:file/@location"
							value="concat( 'http://10.122.91.22:8088/get_message?file='
								, instance( 'instance.mesages' )
									/file[index('messages-repeat')]/@src )" />
						
						<xf:setvalue ref="instance( 'instance.config' )
								/ebforms:schema/@src"
							value="concat( '../prototype-gs1/schemas/',
								instance( 'instance.mesages' )
									/file[index('messages-repeat')]/@schema )" />

						<!-- After that save the changes to a file -->
						<xf:send submission="save.config" />
					</xf:action>
				</xf:trigger>
			</xf:repeat>
		</div>
	</body>
</html>